package router

import (
	"github.com/gin-gonic/gin"
	"gorm.io/gorm"

	systemController "gitee.com/wangshh_123/cross-pay-go/src/controller/system"
	"gitee.com/wangshh_123/cross-pay-go/src/middleware"
)

// SetupCardBalanceSyncRoutes 设置卡片余额同步路由
func SetupCardBalanceSyncRoutes(r *gin.Engine, db *gorm.DB) {
	cardBalanceSyncController := systemController.NewCardBalanceSyncController(db)

	// 卡片余额同步相关路由
	cardBalanceSyncGroup := r.Group("/api/v1/card-balance-sync")
	cardBalanceSyncGroup.Use(middleware.AuthMiddleware())
	{
		// 从API同步卡片余额
		cardBalanceSyncGroup.POST("/sync-from-api", cardBalanceSyncController.SyncCardBalanceFromAPI)

		// 从卡片列表API响应同步余额
		cardBalanceSyncGroup.POST("/sync-from-card-list", cardBalanceSyncController.SyncCardBalanceFromCardListAPI)

		// 获取卡片余额统计
		cardBalanceSyncGroup.GET("/summary", cardBalanceSyncController.GetCardBalanceSummary)

		// 列出余额为0的卡片
		cardBalanceSyncGroup.GET("/zero-balance-cards", cardBalanceSyncController.ListCardsWithZeroBalance)

		// 按平台列出卡片
		cardBalanceSyncGroup.GET("/cards-by-platform", cardBalanceSyncController.ListCardsByPlatform)

		// 手动同步指定卡片的余额
		cardBalanceSyncGroup.POST("/manual-sync", cardBalanceSyncController.ManualSyncCardBalance)
	}
}
